App.controller('stockInventoryController', ['$rootScope', '$scope', '$state', 'Page', function($rootScope, $scope, $state, Page) {

    $scope.grid = {
        add : function() {
            $scope.stockInventory = {};
            $scope.modal.setTitle('新增').show();
        },
        update: function(row) {
            $scope.stockInventory = row;
            $scope.modal.setTitle('编辑').show();
        },
        save : function() {
           Page.ajaxPost($scope.stockInventory.stockId ? 'stockInventory/update.do' : 'stockInventory/add.do', $scope.stockInventory, function() {
               $scope.grid.query();
               $scope.grid.cancel();
           });
        },
        column_defs: [{
            target : 12,
            buttons : [
                {
                    name: '编辑',
                    class: 'btn-warning btm-sm',
                    icon: 'fa-edit',
                    event: 'update'
                }
            ]
        }]
    };

    /*自定义查询*/
    $scope.query = function () {
        $scope.grid.query();
    };

    /*自定义重置*/
    $scope.reset = function () {
        $scope.grid.reset();
    };
}]);